package com.cowin.sys.service.impl;

import com.cowin.sys.dao.TeOfmVehiclePlanMapper;
import com.cowin.sys.dao.TmOfmOrderMapper;
import com.cowin.sys.model.TeOfmVehiclePlan;
import com.cowin.sys.model.vo.PlanDeliveryVo;
import com.cowin.sys.model.vo.PlanSearchVo;
import com.cowin.sys.model.vo.SearchPlanOrderVo;
import com.cowin.sys.model.vo.TeOfmVehiclePlanVo;
import com.cowin.sys.service.TeOfmVehiclePlanService;
import com.cowin.base.AbstractServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * Created by  on 2019/10/30.
 *
 * @author CodeGenerator
 */
@Slf4j
@Service
@Transactional(rollbackFor = RuntimeException.class)
public class TeOfmVehiclePlanServiceImpl extends AbstractServiceImpl<TeOfmVehiclePlan> implements TeOfmVehiclePlanService {

    @Resource
    private TeOfmVehiclePlanMapper teOfmVehiclePlanMapper;

    @Resource
    private TmOfmOrderMapper tmOfmOrderMapper;

    @Override
    public List<Map<String, Object>> getPlanForm(TeOfmVehiclePlanVo teOfmVehiclePlanVo) {
        List<Map<String, Object>> list = new ArrayList<>();
        if (teOfmVehiclePlanVo.getIsMinutia()!=null &&teOfmVehiclePlanVo.getIsMinutia()) {
            //查询明细
            list = tmOfmOrderMapper.findMinutia(teOfmVehiclePlanVo);
            return list;
        } else if (teOfmVehiclePlanVo.getIsMinutia()!=null&&!teOfmVehiclePlanVo.getIsMinutia()) {
            //查询汇总
            list = teOfmVehiclePlanMapper.findSummary(teOfmVehiclePlanVo);
            return list;
        }
        return list;
    }

    @Override
    public List<PlanSearchVo> searchPlan(PlanSearchVo planSearchVo) {
        return teOfmVehiclePlanMapper.findPlan(planSearchVo);
    }

    @Override
    public List<PlanDeliveryVo> getDelivery(String batchNo,int num) {
        return teOfmVehiclePlanMapper.findDelivery(batchNo,num);
    }

    @Override
    public List<SearchPlanOrderVo> searchPlanByOrder(SearchPlanOrderVo searchPlanOrderVo) {
        return teOfmVehiclePlanMapper.findPlanByOrder(searchPlanOrderVo);
    }
}
